package com.church.action;

import java.util.Map;

import com.church.db.Tasklist;
import com.church.services.TasklistServices;
import com.opensymphony.xwork2.ActionContext;

public class GetTask {
	private TasklistServices tasklistServices;
	private Tasklist tasklist;
	private long id;

	public TasklistServices getTasklistServices() {
		return tasklistServices;
	}

	public void setTasklistServices(TasklistServices tasklistServices) {
		this.tasklistServices = tasklistServices;
	}

	public Tasklist getTasklist() {
		return tasklist;
	}

	public void setTasklist(Tasklist tasklist) {
		this.tasklist = tasklist;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String execute() {
		ActionContext actionContext = ActionContext.getContext();
		Map session = actionContext.getSession();
		String userGroup = (String) session.get("USER_GROUP");
		String userType = (String) session.get("USER_TYPE");
		if (userGroup != null && userType != null) {
			if (!userGroup.equals("user")) {
				tasklist = tasklistServices.getTaskById(id);
			}
		}
		return "success";
	}
}
